package backtrack;
import java.util.*;
public class _08_78_子集 {
	List<List<Integer>> result = new ArrayList<>();
	List<Integer> item = new ArrayList<>();
    public List<List<Integer>> subsets(int[] nums) {
    	Arrays.sort(nums);
    	backtracking(nums,0);
    	return result;
    }
    
    public void backtracking(int[] nums, int index) {
    	result.add(new ArrayList<Integer>(item));
    	System.out.println(item);
    	for(int i = index; i < nums.length; i++) {
    		item.add(nums[i]);
    		backtracking(nums, i + 1);
    		item.remove(item.size() - 1);
    	}
    	
    }
    
    public static void main(String[] args) {
    	int[] nums = {1,2,2};
		new _08_78_子集().subsets(nums);
	}
}
